package patrol.mobile.com.mobilepatrol.activity.security.emergency;

import android.annotation.SuppressLint;
import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import java.util.List;

import butterknife.BindView;
import patrol.mobile.com.mobilepatrol.R;
import patrol.mobile.com.mobilepatrol.activity.office.HomeDataHelper;
import patrol.mobile.com.mobilepatrol.activity.office.OtherBusinessSearchActivity;
import patrol.mobile.com.mobilepatrol.adapter.MyHomeAdapter;
import patrol.mobile.com.mobilepatrol.bean.HomeDataBean;
import patrol.mobile.com.mobilepatrol.bean.MenuBean;
import patrol.mobile.com.mobilepatrol.bean.MenuConstants;
import patrol.mobile.com.mobilepatrol.fragment.BaseFragment;

/**
 * Created by fuzhen.li on 2018/9/18.
 */
public class EmergencyZHFragment extends BaseFragment {

    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;
    @BindView(R.id.tv_HZ)
    TextView tv_HZ;
    List<MenuBean> menuBeanList;
    protected MyHomeAdapter mAdapter;
    public EmergencyZHFragment(){}
    @SuppressLint("ValidFragment")
    public EmergencyZHFragment(List<MenuBean> menuBeanList) {
        this.menuBeanList=menuBeanList;
    }

//    private static final String[] stringsTop = new String[]{"应急管理", "安全生产", "综治维稳和平安建设", "包联包户", "其它业务查询"};
//    private static final String[] stringsSub1 = new String[]{"应急保障基地", "应急机制", "应急预案体系", "应急演练", "应急事件统计"};//"应急检查","安全考核汇总","应急保障机制"
//    private static final String[] stringsSub2 = new String[]{"安全生产机构", "安全教育", "作业区专项检查", "外包工程基本情况", "安全检查"};//"安全事故处理", , "定期检查",
//    //    private static final String[] stringsSub3 = new String[]{"护队花名册", "维稳器材汇总", "节日值班表", "值带班检查", "综治维稳定期检查", "包联包户","防爆汇总1","防爆汇总2","包联领导","包联编辑1"};
//    private static final String[] stringsSub3 = new String[]{"护队花名册", "维稳器材汇总", "节日值班表", "值带班检查"};//"综治维稳检查",
//    private static final String[] stringsSub4 = new String[]{"包联包户"};//"综治维稳检查",
//    private static final String[] stringsSub5 = new String[]{"其它业务查询"};//其它业务查询,
//    private static final int[] img1 = new int[]{R.mipmap.emergency_base, R.mipmap.emergency_mechanism, R.mipmap.ntingency_plan, R.mipmap.emergency_rehearsal, R.mipmap.security_check, R.mipmap.emergency_statistics, R.mipmap.assess_pool, R.mipmap.assess_pool};
//    private static final int[] img1 = new int[]{R.mipmap.emergency_base, R.mipmap.emergency_mechanism, R.mipmap.ntingency_plan, R.mipmap.emergency_rehearsal, R.mipmap.security_check};
//    // private static final int[] img2 = new int[]{R.mipmap.organization, R.mipmap.safety_education, R.mipmap.accident_treatment, R.mipmap.accident_treatment, R.mipmap.chance_inspect, R.mipmap.periodic_inspection, R.mipmap.ectocy_administration};
//    private static final int[] img2 = new int[]{R.mipmap.organization, R.mipmap.safety_education, R.mipmap.accident_treatment, R.mipmap.accident_treatment, R.mipmap.chance_inspect};
//    //    private static final int[] img3 = new int[]{R.mipmap.roster, R.mipmap.equipment_summary, R.mipmap.holiday_rota, R.mipmap.check_duty, R.mipmap.comprehensive_examination, R.mipmap.packs, R.mipmap.comprehensive_examination, R.mipmap.ntingency_plan, R.mipmap.emergency_statistics, R.mipmap.chance_inspect};
//    //private static final int[] img3 = new int[]{R.mipmap.roster, R.mipmap.equipment_summary, R.mipmap.holiday_rota, R.mipmap.check_duty, R.mipmap.comprehensive_examination, R.mipmap.packs};
//    private static final int[] img3 = new int[]{R.mipmap.roster, R.mipmap.equipment_summary, R.mipmap.holiday_rota, R.mipmap.check_duty, R.mipmap.comprehensive_examination};
//    private static final int[] img4 = new int[]{R.mipmap.comprehensive_examination};
//    private static final int[] img5 = new int[]{R.mipmap.other_queries};

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_zh_1;
    }

    @Override
    protected void initView() {
        super.initView();
    }

    @Override
    protected void initData() {
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        mAdapter = new MyHomeAdapter(getContext());
        recyclerView.setAdapter(mAdapter);
        mAdapter.setData(initAdapterData());
    }

    private List<HomeDataBean> initAdapterData() {
        return HomeDataHelper.getInstance().getHomeDataYW(
                MenuConstants.ABGL_TAB1_TOP_TITLES,
                MenuConstants.ABGL_TAB1_CHILD_TITLES_1,
                MenuConstants.ABGL_TAB1_CHILD_TITLES_2,
                MenuConstants.ABGL_TAB1_CHILD_TITLES_3,
                MenuConstants.ABGL_TAB1_CHILD_TITLES_4,
                MenuConstants.ABGL_TAB1_CHILD_IMG_1,
                MenuConstants.ABGL_TAB1_CHILD_IMG_2,
                MenuConstants.ABGL_TAB1_CHILD_IMG_3,
                MenuConstants.ABGL_TAB1_CHILD_IMG_4
                );
    }

    @Override
    protected void initTitle() {
        super.initTitle();

    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);

    }

    @Override
    protected void initListener() {
        tv_HZ.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(EmergencySaveCollectionActivity.class);//安全管理考核汇总
            }
        });


        mAdapter.setItemClickListener(new MyHomeAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(int parentPosition, int childPosition) {
                if (parentPosition == 0) {
                    if (childPosition == 0) {
                        //startActivity(ExaminationAllActivity.class);//应急保障基地
                        startActivity(EmergencyEnsure1Activity.class);//应急保障基地
                    } else if (childPosition == 1) {
                        //startActivity(ExaminationAllActivity.class);//应急机制
                        //startActivity(Emergency1Activity.class);//应急机制
                        startActivity(EmergencyEnsureMadeActivity.class);//应急保障机制
                    } else if (childPosition == 2) {
                        // startActivity(ExaminationAllActivity.class);//应急预案体系
                        startActivity(EmergencyPlan1Activity.class);//应急预案体系
                    } else if (childPosition == 3) {
                        // startActivity(TrafficAllActivity.class);//应急演练
                        startActivity(EmergencyDrill1Activity.class);//应急演练
                    }
//                    else if (childPosition == 4) {
//                        //startActivity(SummaryOfChargesActivity.class);//应急检查
//                        startActivity(EmergencyCheck1Activity.class);//应急检查
//                    }
                    else if (childPosition == 4) {
                        //startActivity(OtherBusinessSearchActivity.class);//应急事件统计
                        startActivity(EmergencyEvent1Activity.class);//应急事件统计
                    }

//                    else if (childPosition == 6){
//                        startActivity(EmergencySaveCollectionActivity.class);//安全管理考核汇总
//                    }else{
//                        startActivity(EmergencyEnsureMadeActivity.class);//应急保障机制
//                    }
                } else if (parentPosition == 1) {
                    if (childPosition == 0) {
                        // startActivity(JobEvaluationActivity.class);//安全生产组织机构
                        startActivity(EmergencySaveAgency1Activity.class);//安全生产组织机构
                    } else if (childPosition == 1) {
                        //startActivity(MyEvaluationActivity.class);//安全教育
                        startActivity(EmergencySaveEdu1Activity.class);//安全教育
                    }
//
//                    else if (childPosition == 2) {
//                        //startActivity(TrafficChargeActivity.class);//安全事故处理
//                        startActivity(EmergencySaveThingsDeal1Activity.class);//安全事故处理
//                    }
//                    else if (childPosition == 3) {
//                        //startActivity(TrafficChargeActivity.class);//安全检查
//                        startActivity(EmergencySaveCheckLeader1Activity.class);//安全检查
//                    }
                    else if (childPosition == 2) {
                        // startActivity(TrafficChargeActivity.class);//作业区专项检查
                        //startActivity(EmergencyCuring1Activity.class);//作业区专项检查
                        startActivity(ZHCXEmergencyCuring1Activity.class);//作业区专项检查
                    }
//                    else if (childPosition == 5) {
//                        startActivity(TrafficChargeActivity.class);//定期检查
//                    }
                    else if (childPosition == 3) {
                        //startActivity(TrafficChargeActivity.class);//外包工程安全管理
                        startActivity(EmergencyOutSaveManager1Activity.class);//外包工程安全管理
                    } else if (childPosition == 4) {
                        //startActivity(TrafficChargeActivity.class);//安全检查
                        startActivity(EmergencySaveCheckLeader1Activity.class);//安全检查
                    }
                } else if (parentPosition == 2) {
                    if (childPosition == 0) {
                        //护队花名册
                        startActivity(EmergencyProtectActivity.class);
                    } else if (childPosition == 1) {
                        //防爆器材汇总
                        //startActivity(EmergencyAvoidExplode1Activity.class);
                        startActivity(AvoidActivity.class);
                    } else if (childPosition == 2) {
                        // startActivity(ExaminationAllActivity.class);//节日值班表
                        startActivity(EmergencyFestivalDutyActivity.class);//节日值班表
                    } else if (childPosition == 3) {
                        // startActivity(TrafficAllActivity.class);//值带班检查
                        //startActivity(EmergencyProtectCollectionActivity.class);//值带班检查
                        startActivity(ZHCXEmergencyProtectCollectionActivity.class);//值带班检查
                    }
//                    else if (childPosition == 4) {
//                        startActivity(SummaryOfChargesActivity.class);//综治维稳定期检查
//                    }
//                    else if (childPosition == 4) {
//                        //startActivity(OtherBusinessSearchActivity.class);//包联包户
//                        startActivity(EmergencyProtectListActivity.class);//包联包户
//                    }
//                    else if (childPosition == 6) {
//                        startActivity(EmergencyAvoidExplode1Activity.class);//防爆汇总1
//                    } else if (childPosition == 7) {
//                        startActivity(EmergencyAvoidExplode2Activity.class);//防爆汇总2
//                    } else if (childPosition == 8) {
//                        startActivity(EmergencyPackageLeaderSeeActivity.class);//包联领导
//                    } else if (childPosition == 9) {
//                        //startActivity(EmergencyPackageEdit1Activity.class);//包联编辑1
//                    }
                } else if (parentPosition == 3) {
                    if (childPosition == 0) {
                        // startActivity(EmergencyProtectListActivity.class);//包联包户
                        startActivity(ZHCXEmergencyProtectListActivity.class);//包联包户
                    }
                }else if (parentPosition == 4){
                    startActivity(OtherBusinessSearchActivity.class);
                }
            }
        });

    }

}
